// A-S-M team
// Project: BattleCity
// Created: 23.03.2011
// Last change: 26.03.2011
// Description: implementation class "Game" - logic of game

#include "game.h"
#include "painter.h"
#include "menu.h"
#include "application.h"

#include <ClanLib/application.h>
#include <ClanLib/core.h>
#include <ClanLib/display.h>

Game * Game::p_instance = NULL;

bool Game::update(int dt)
{
	switch (_game_state)
	{
	case GS_MENU:
		return menu.update(dt);
		break;
	case GS_PLAY:
		return Play::getInstance()->update(dt);
		break;
	case GS_EDITOR:
		return true;
		break;
	default:
		return true;
		break;
	}
}

void Game::keyDown(int key)
{
	switch (_game_state)
	{
	case GS_MENU:
		menu.keyDown(key);
		break;
	case GS_PLAY:
		Play::getInstance()->keyDown(key);
		break;
	case GS_EDITOR:
		return;
		break;
	default:
		return;
		break;
	}

}

void Game::keyUp(int key)
{
	switch (_game_state)
	{
	case GS_MENU:
		menu.keyUp(key);
		break;
	case GS_PLAY:
		Play::getInstance()->keyUp(key);
		break;
	case GS_EDITOR:
		return;
		break;
	default:
		return;
		break;
	}
}

void Game::keyPress(const CL_InputEvent &key)
{
	switch (_game_state)
	{
	case GS_MENU:
		menu.keyPress(key.id);
		break;
	case GS_PLAY:
		Play::getInstance()->keyPress(key.id);
		break;
	case GS_EDITOR:
		return;
		break;
	default:
		return;
		break;
	}
}